import request from "@/utils/request";
import type {
	OrderIdResponseData,
	OrderInfoResponseData,
	PayInfo,
	QRCodeResponseData,
	UserInfoResponseData,
	IdTypeResponseData,
	UserParams,
	OrderListResponseData,
	PatientListResponseData,
	OrderStatusResponseData,
	CityResponseData,
} from "@/api/user/type";

enum API {
	// 提交订单时，获取订单id
	ORDER_URL = '/order/orderInfo/auth/submitOrder/',
	// 获取订单详情数据
	GETORDER_URL = '/order/orderInfo/auth/getOrderInfo/',
	// 取消订单接口
	CANCEL_URL = '/order/orderInfo/auth/cancelOrder/',
	// 获取支付订单二维码
	QRCODE_URL = '/order/weixin/createNative/',
	//查询订单支付结果
	PAYSTATUS_URL = '/order/weixin/queryPayStatus/',
	//获取当前账号的认证信息
	USERINFO_URL = '/user/auth/getUserInfo',
	// 获取证件类型（身份证还是户口本）
	IDTYPE_URL = '/cmn/dict/findByDictCode/',
	// 用户认证的接口
	USERINFO_AUDIT_URL = '/user/auth/userAuah',
	// 获取用户所有订单列表
	ORDERLIST_URL = '/order/orderInfo/auth/',
	// 获取全部就诊人
	PATIENT_URL = '/user/patient/auth/findAll',
	// 获取订单状态
	ORDERSTATUS_URL = '/order/orderInfo/auth/getStatusList/',
	// 获取城市
	CITY_URL = '/cmn/dict/findByParentId/',
}

// 提交订单
export const reqOrder = (hoscode: string,scheduleId: string, patientId: string) =>
	request.post<any, OrderIdResponseData>(API.ORDER_URL+`${hoscode}/${scheduleId}/${patientId}`);

// 获取订单详情数据
export const reqOrderDetail = (orderId: string) =>
	request.get<any, OrderInfoResponseData>(API.GETORDER_URL+orderId);

// 取消订单
export const reqCancelOrder = (orderId: string) =>
	request.get<any, any>(API.CANCEL_URL+orderId);

// 获取支付订单二维码
export const reqQrcode = (orderId: string) =>
	request.get<any, QRCodeResponseData>(API.QRCODE_URL+orderId);

// 查询订单支付结果
export const reqPayStatus = (orderId: string) =>
	request.get<any, PayInfo>(API.PAYSTATUS_URL+orderId);

// 获取当前账号的认证信息
export const reqUserInfo = () => request.get<any, UserInfoResponseData>(API.USERINFO_URL);

// 获取证件类型（身份证还是户口本）
export const reqIdType = (CertificatesType='CertificatesType') => request.get<any, IdTypeResponseData>(API.IDTYPE_URL+CertificatesType);

// 用户认证
export const reqUserAudit = (userInfo: UserParams) => request.post<any, any>(API.USERINFO_AUDIT_URL, userInfo);

// 获取用户所有订单列表
export const reqOrderList = (page: number,limit: number,patientId:string,orderStatus: string) =>
	request.get<any, OrderListResponseData>(API.ORDERLIST_URL+`${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`);

// 获取全部就诊人
export const reqPatient = () => request.get<any, PatientListResponseData>(API.PATIENT_URL);

// 获取订单状态
export const reqOrderStatus = () => request.get<any, OrderStatusResponseData>(API.ORDERSTATUS_URL);

// 获取城市
export const reqCity = (parentId: string) => request.get<any, CityResponseData>(API.CITY_URL+parentId);